36 Lecture

CS402

Midterm & Final Term Short Notes

Chomsky Normal Form (CNF)

Chomsky Normal Form (CNF) is a specific type of context-free grammar (CFG) in which all production rules are in the form A ? BC or A ? a, where A, B, and C are nonterminal symbols, and a is a terminal symbol. In CNF, each nonterminal symbol gene


Important Mcq's
Midterm & Finalterm Prepration
Past papers included

Download PDF
  1. Which of the following is true about Chomsky Normal Form (CNF)? A) All nonterminal symbols can generate epsilon B) All nonterminal symbols can generate at most one terminal symbol C) All nonterminal symbols can generate at most two nonterminal symbols D) All nonterminal symbols can generate both terminal and nonterminal symbols Answer: C What is the benefit of converting a context-free grammar (CFG) to Chomsky Normal Form (CNF)? A) It eliminates all nonterminal symbols B) It makes the grammar more complex C) It simplifies parsing by removing ambiguity D) It increases the number of productions Answer: C Which of the following statements is true about Chomsky Normal Form (CNF) grammars? A) They are more expressive than regular grammars B) They are less expressive than context-free grammars C) They are equivalent in expressive power to context-free grammars D) They are only used for parsing programming languages Answer: C What is the form of the production rules in Chomsky Normal Form (CNF)? A) A ? aB B) A ? a C) A ? BC D) A ? ? Answer: C How many nonterminal symbols can appear on the right-hand side of a production rule in Chomsky Normal Form (CNF)? A) None B) One C) Two D) Three Answer: C What is the purpose of converting a CFG to Chomsky Normal Form (CNF)? A) To increase the number of productions B) To remove all terminal symbols C) To eliminate ambiguity in parsing D) To make the grammar more complex Answer: C Which of the following is an example of a production rule in Chomsky Normal Form (CNF)? A) A ? aB B) A ? B C) A ? BC D) A ? ? Answer: C Can every context-free grammar be converted to Chomsky Normal Form (CNF)? A) Yes B) No Answer: A Which of the following is not allowed in Chomsky Normal Form (CNF)? A) Production rules with one nonterminal symbol and one terminal symbol B) Production rules with only one nonterminal symbol C) Production rules with more than two nonterminal symbols D) Production rules with epsilon on the right-hand side Answer: C What is the advantage of Chomsky Normal Form (CNF) over other forms of context-free grammars? A) It can handle regular languages B) It has fewer production rules C) It makes parsing more efficient D) It can handle non-context-free languages Answer: C


Subjective Short Notes
Midterm & Finalterm Prepration
Past papers included

Download PDF
  1. What is Chomsky Normal Form (CNF) in the context of Context-Free Grammar? Answer: Chomsky Normal Form (CNF) is a standard form of Context-Free Grammar in which all production rules have the form A -> BC or A -> a, where A, B, and C are non-terminal symbols, and a is a terminal symbol. Why is it useful to convert a Context-Free Grammar to Chomsky Normal Form? Answer: Converting a Context-Free Grammar to Chomsky Normal Form makes it easier to analyze and manipulate. It simplifies the structure of the grammar and allows for more efficient parsing algorithms to be used. How can we convert a Context-Free Grammar to Chomsky Normal Form? Answer: The conversion process involves the following steps: Remove all productions with epsilon (?) on the right-hand side. Replace all unit productions with the original non-terminal symbol. Eliminate all non-terminal symbols that do not produce any terminal symbols. Replace all remaining productions with a length greater than 2 with a series of productions with two non-terminals on the right-hand side. What is the benefit of having Chomsky Normal Form? Answer: Chomsky Normal Form simplifies the structure of the grammar and allows for more efficient parsing algorithms to be used. It also provides a way to prove certain properties of the grammar, such as ambiguity. What are the limitations of Chomsky Normal Form? Answer: Chomsky Normal Form only applies to context-free grammars, and not all context-free grammars can be converted to CNF. The conversion process can also result in an increase in the number of production rules. What is the difference between a context-free grammar and a grammar in Chomsky normal form? Answer: A context-free grammar is a formal grammar consisting of a set of production rules that generate a set of strings in a language. A grammar in Chomsky Normal Form is a specific form of a context-free grammar where all production rules have the form A -> BC or A -> a, where A, B, and C are non-terminal symbols, and a is a terminal symbol. What is the significance of having only unit or binary production rules in Chomsky Normal Form? Answer: Having only unit or binary production rules in Chomsky Normal Form makes it easier to generate parse trees and to apply parsing algorithms. It simplifies the structure of the grammar and allows for more efficient processing. Can every Context-Free Grammar be converted into Chomsky Normal Form? Answer: Yes, every context-free grammar can be converted into Chomsky Normal Form. How does Chomsky Normal Form simplify parsing algorithms? Answer: Chomsky Normal Form simplifies parsing algorithms by reducing the complexity of the grammar. This allows for more efficient algorithms to be used, such as the CYK algorithm. What is the difference between Chomsky Normal Form and Greibach Normal Form? Answer: Chomsky Normal Form and Greibach Normal Form are two standard forms of context-free grammars. The main difference is the form of the production rules. In Chomsky Normal Form, all production rules are of the form A -> BC or A -> a, where A, B, and C are non-terminal symbols, and a is a terminal symbol. In Greibach Normal Form, the production rules are of the form A -> aB, where A and B are non-terminal symbols, and a is a terminal symbol.

Chomsky Normal Form (CNF) is a specific form of Context-Free Grammar (CFG) that restricts the grammar rules to a specific format. CNF rules are in the form of A ? BC or A ? a, where A, B, and C are non-terminal symbols and a is a terminal symbol. The conversion of a CFG to CNF involves several steps, such as removing all ?-productions, unit productions, and non-reachable symbols. Then, any non-terminal with more than two symbols in its productions is replaced by a new non-terminal. Finally, all productions are either of the form A ? BC or A ? a. The main benefit of CNF is that it simplifies the parsing process, making it more efficient. It also makes it easier to reason about the properties of the language generated by the grammar. To convert a CFG to CNF, we need to follow specific steps, which include:
  1. Removing ?-productions
  2. Removing unit productions
  3. Removing non-reachable symbols
  4. Removing productions with more than two non-terminals
  5. Eliminating remaining productions to be in CNF form
Although converting a CFG to CNF can be time-consuming, it can be useful in applications such as natural language processing, compiler design, and parsing algorithms.